package com.fare.taluo.io.excel;

import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.VerticalAlignment;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WriteException;
/**
 * 导出Excel经典样式
 * @author xiangsf 2012-6-6
 *
 */
public abstract class ExcelExportClassicStyle extends ExportExcel {
	/**
	 * 大标题,宋体粗体字,居中,细线条全边框,24号字体
	 */
	protected WritableFont fontBoldTitle;//宋体粗体字,24号字体
	protected WritableCellFormat cellFormatTitle;
	/**
	 * 副标题,宋体粗体字,居右,细线条全边框,18号字体
	 */
	protected WritableFont fontBoldSubTitle;//宋体粗体字,18号字体
	protected WritableCellFormat cellFormatSubTitle;
	/**
	 * 附加说明,宋体普通字,居左,细线条全边框,10号字体
	 */
	protected WritableFont fontSt12;//宋体普通字,10号字体
	protected WritableCellFormat cellFormatAdditionInfo;
	/**
	 * 附加说明中着重单元格,宋体粗体字,居右,细线条全边框,10号字体
	 */
	protected WritableFont fontBlodSt12;//宋体粗体字,10号字体
	protected WritableCellFormat cellFormatAdditionImportantInfo;
	/**
	 * 列头标题，宋体粗体字,居中,细线条全边框,10号字体,蓝色背景色
	 */
	protected WritableFont fontBlodRedSt12;//宋体粗体红色字,12号字体
	protected WritableCellFormat cellFormatColHeadCenter;
	protected WritableCellFormat cellFormatColHeadLeft;
	protected WritableCellFormat cellFormatColHeadRight;
	protected WritableCellFormat cellFormatColHeadCenterAndRed;
	protected WritableCellFormat cellFormatColHeadLeftAndRed;
	protected WritableCellFormat cellFormatColHeadRightAndRed;
	/**
	 * 单行单元格，宋体普通字,居左/中/右,细线条全边框,10号字体,白色背景色
	 */
	protected WritableCellFormat cellFormatCellWriteLeft;
	protected WritableCellFormat cellFormatCellWriteCenter;
	protected WritableCellFormat cellFormatCellWriteRight;
	/**
	 * 双行单元格，宋体普通字,居左/中/右,细线条全边框,10号字体,浅蓝背景色
	 */
	protected WritableCellFormat cellFormatCellLightBlueLeft;
	protected WritableCellFormat cellFormatCellLightBlueCenter;
	protected WritableCellFormat cellFormatCellLightBlueRight;
	
	public ExcelExportClassicStyle(){
		super();
	}
	
	protected void initExcelFormat() throws WriteException {
		fontBoldTitle = new WritableFont(WritableFont.createFont("宋体"), 24, WritableFont.BOLD);
		cellFormatTitle = new WritableCellFormat(fontBoldTitle);
		cellFormatTitle.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatTitle.setAlignment(Alignment.CENTRE);
		cellFormatTitle.setBorder(Border.ALL, BorderLineStyle.THIN);
		
		fontBoldSubTitle = new WritableFont(WritableFont.createFont("宋体"), 18, WritableFont.BOLD);
		cellFormatSubTitle = new WritableCellFormat(fontBoldSubTitle);
		cellFormatSubTitle.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatSubTitle.setAlignment(Alignment.RIGHT);
		cellFormatSubTitle.setBorder(Border.ALL, BorderLineStyle.THIN);
		
		fontSt12 = new WritableFont(WritableFont.createFont("宋体"), 10, WritableFont.NO_BOLD);
		cellFormatAdditionInfo = new WritableCellFormat(fontSt12);
		cellFormatAdditionInfo.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatAdditionInfo.setAlignment(Alignment.LEFT);
		cellFormatAdditionInfo.setBorder(Border.ALL, BorderLineStyle.THIN);
		
		fontBlodSt12 = new WritableFont(WritableFont.createFont("宋体"), 10, WritableFont.BOLD);
		cellFormatAdditionImportantInfo = new WritableCellFormat(fontBlodSt12);
		cellFormatAdditionImportantInfo.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatAdditionImportantInfo.setAlignment(Alignment.RIGHT);
		cellFormatAdditionImportantInfo.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatAdditionImportantInfo.setBackground(Colour.getInternalColour(22));
		
		cellFormatColHeadCenter = new WritableCellFormat(fontBlodSt12);
		cellFormatColHeadCenter.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatColHeadCenter.setAlignment(Alignment.CENTRE);
		cellFormatColHeadCenter.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatColHeadCenter.setBackground(Colour.PALE_BLUE);
		cellFormatColHeadCenter.setWrap(true);
		
		cellFormatColHeadLeft = new WritableCellFormat(fontBlodSt12);
		cellFormatColHeadLeft.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatColHeadLeft.setAlignment(Alignment.LEFT);
		cellFormatColHeadLeft.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatColHeadLeft.setBackground(Colour.PALE_BLUE);
		cellFormatColHeadLeft.setWrap(true);
		
		cellFormatColHeadRight = new WritableCellFormat(fontBlodSt12);
		cellFormatColHeadRight.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatColHeadRight.setAlignment(Alignment.RIGHT);
		cellFormatColHeadRight.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatColHeadRight.setBackground(Colour.PALE_BLUE);
		cellFormatColHeadRight.setWrap(true);
		
		cellFormatCellWriteLeft = new WritableCellFormat(fontSt12);
		cellFormatCellWriteLeft.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatCellWriteLeft.setAlignment(Alignment.LEFT);
		cellFormatCellWriteLeft.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatCellWriteLeft.setBackground(Colour.WHITE);
		cellFormatCellWriteLeft.setWrap(true);
		
		cellFormatCellWriteRight = new WritableCellFormat(fontSt12);
		cellFormatCellWriteRight.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatCellWriteRight.setAlignment(Alignment.RIGHT);
		cellFormatCellWriteRight.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatCellWriteRight.setBackground(Colour.WHITE);
		cellFormatCellWriteRight.setWrap(true);
		
		cellFormatCellWriteCenter = new WritableCellFormat(fontSt12);
		cellFormatCellWriteCenter.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatCellWriteCenter.setAlignment(Alignment.CENTRE);
		cellFormatCellWriteCenter.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatCellWriteCenter.setBackground(Colour.WHITE);
		cellFormatCellWriteCenter.setWrap(true);
		
		cellFormatCellLightBlueLeft = new WritableCellFormat(fontSt12);
		cellFormatCellLightBlueLeft.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatCellLightBlueLeft.setAlignment(Alignment.LEFT);
		cellFormatCellLightBlueLeft.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatCellLightBlueLeft.setBackground(Colour.LIGHT_TURQUOISE);
		cellFormatCellLightBlueLeft.setWrap(true);
		
		cellFormatCellLightBlueCenter = new WritableCellFormat(fontSt12);
		cellFormatCellLightBlueCenter.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatCellLightBlueCenter.setAlignment(Alignment.CENTRE);
		cellFormatCellLightBlueCenter.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatCellLightBlueCenter.setBackground(Colour.LIGHT_TURQUOISE);
		cellFormatCellLightBlueCenter.setWrap(true);
		
		cellFormatCellLightBlueRight = new WritableCellFormat(fontSt12);
		cellFormatCellLightBlueRight.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatCellLightBlueRight.setAlignment(Alignment.RIGHT);
		cellFormatCellLightBlueRight.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatCellLightBlueRight.setBackground(Colour.LIGHT_TURQUOISE);
		cellFormatCellLightBlueRight.setWrap(true);
		
		fontBlodRedSt12 = new WritableFont(WritableFont.createFont("宋体"), 12, WritableFont.BOLD);
		fontBlodRedSt12.setColour(Colour.RED);
		cellFormatColHeadCenterAndRed = new WritableCellFormat(fontBlodRedSt12);
		cellFormatColHeadCenterAndRed.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatColHeadCenterAndRed.setAlignment(Alignment.CENTRE);
		cellFormatColHeadCenterAndRed.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatColHeadCenterAndRed.setBackground(Colour.PALE_BLUE);
		cellFormatColHeadCenterAndRed.setWrap(true);
		
		cellFormatColHeadLeftAndRed = new WritableCellFormat(fontBlodRedSt12);
		cellFormatColHeadLeftAndRed.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatColHeadLeftAndRed.setAlignment(Alignment.LEFT);
		cellFormatColHeadLeftAndRed.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatColHeadLeftAndRed.setBackground(Colour.PALE_BLUE);
		cellFormatColHeadLeftAndRed.setWrap(true);
		
		cellFormatColHeadRightAndRed = new WritableCellFormat(fontBlodRedSt12);
		cellFormatColHeadRightAndRed.setVerticalAlignment(VerticalAlignment.CENTRE);
		cellFormatColHeadRightAndRed.setAlignment(Alignment.RIGHT);
		cellFormatColHeadRightAndRed.setBorder(Border.ALL, BorderLineStyle.THIN);
		cellFormatColHeadRightAndRed.setBackground(Colour.PALE_BLUE);
		cellFormatColHeadRightAndRed.setWrap(true);
	}
	
	protected void clearResource(){
		fontBoldTitle = null;//宋体粗体字,24号字体
		cellFormatTitle = null;

		fontBoldSubTitle = null;//宋体粗体字,18号字体
		cellFormatSubTitle = null;

		fontSt12 = null;//宋体普通字,12号字体
		cellFormatAdditionInfo = null;

		fontBlodSt12 = null;//宋体粗体字,12号字体
		cellFormatAdditionImportantInfo = null;

		fontBlodRedSt12 = null;//宋体粗体红色字,12号字体
		cellFormatColHeadCenter = null;
		cellFormatColHeadLeft = null;
		cellFormatColHeadRight = null;
		cellFormatColHeadCenterAndRed = null;
		cellFormatColHeadLeftAndRed = null;
		cellFormatColHeadRightAndRed = null;

		cellFormatCellWriteLeft = null;
		cellFormatCellWriteCenter = null;
		cellFormatCellWriteRight = null;

		cellFormatCellLightBlueLeft = null;
		cellFormatCellLightBlueCenter = null;
		cellFormatCellLightBlueRight = null;
	}

}
